import { FormRules } from "element-plus"

export const basicDatumFormRules: FormRules = {
  userName: [{ required: true, message: "请输入用户名", trigger: "blur" }],
  phone: [
    { required: true, message: "请输入手机号", trigger: "blur" },
    {
      trigger: "blur",
      validator: (rule, val, cb) => {
        const valToNumber = Number(val)
        if (Number.isInteger(valToNumber) && val.length === 11) {
          cb()
        } else {
          console.log(valToNumber, val)
          cb(new Error("请输入11位的国内手机号"))
        }
      }
    }
  ],
  email: [{ type: "string", message: "请输入邮箱", trigger: "blur" }],
  gender: [
    {
      trigger: "change",
      validator: (rule, val, cb) => {
        if (Number(val) !== 0 && Number(val) !== 1) {
          cb(new Error("请选择单选框中的性别"))
        } else {
          cb()
        }
      }
    }
  ],
  userProfile: [{ type: "string" }]
}

export const workExpectationsFormRules: FormRules = {
  studyingExperience: [{ required: true, message: "请选择学历", trigger: "change" }],
  workName: [{ required: true, message: "请输入职位名称", trigger: "blur" }],
  workPrice: [{ required: true, message: "请选择期望薪资", trigger: "change" }],
  workTime: [{ required: true, message: "请选择工作经验", trigger: "change" }]
}
